<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('notices', function (Blueprint $table) {
            $table->id()->comment('主键id');
            $table->string('title', 100)->comment('通知标题');
            $table->char('type', 1)->comment('通知类型');
            $table->char('level', 1)->nullable()->comment('通知等级');
            $table->tinyInteger('targetType')->comment('目标类型(1-全体 2-指定)');
            $table->text('content')->comment('通知内容');
            $table->tinyInteger('publishStatus')->default(0)->comment('发布状态(0-未发布 1-已发布 -1-已撤回)');
            $table->timestamp('publishTime')->nullable()->comment('发布时间（秒级时间戳）');
            $table->timestamp('revokeTime')->nullable()->comment('撤回时间（秒级时间戳）');
            $table->json('targetUserIds')->nullable()->comment('指定用户id');
            $table->integer('publishId')->nullable()->comment('发布人id');
            $table->timestamp('createTime')->nullable()->comment('创建时间（秒级时间戳）');
            $table->timestamp('updateTime')->nullable()->comment('更新时间（秒级时间戳）');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('notices');
    }
};
